// ActionScript file
import com.founder.framework.common.FounderUtils;
import com.founder.framework.common.StringUtils;
import com.qjz.controller.StudentInfoController;
import com.qjz.entity.StudentInfoVo;
import com.qjz.model.StudentInfoModel;

import mx.events.FlexEvent;
import mx.managers.PopUpManager;

[Bindable]
public var model:StudentInfoModel;
private var controller:StudentInfoController;
[Bindable]
public var dataList:ArrayCollection;

protected function btnSearch_clickHandler(event:MouseEvent):void
{
	var student:StudentInfoVo=model.studentInfoQueryParameter.studentInfo;
	
	if(!StringUtils.isNullOrEmpty(txtXingMing.text))
		student.xingMing=StringUtils.trim(txtXingMing.text);
	if(!StringUtils.isNullOrEmpty(txtXueJiHao.text))
		student.xueJiHao=StringUtils.trim(txtXueJiHao.text);
	if(!StringUtils.isNullOrEmpty(txtSFZH.text))
		student.shenFenZheng=StringUtils.trim(txtSFZH.text);	
	var zhuangTai:String="";
	if(cb1.selected)
		zhuangTai += "'" + cb1.label +"',";
	if(cb2.selected)
		zhuangTai += "'" + cb2.label +"',";
	if(cb3.selected)
		zhuangTai += "'" + cb3.label +"',";
	if(cb4.selected)
		zhuangTai += "'" + cb4.label +"',";
	if(cb5.selected)
		zhuangTai += "'" + cb5.label +"',";
	if(cb6.selected)
		zhuangTai += "'" + cb6.label +"',";				
	if(cb7.selected)
		zhuangTai += "'" + cb7.label +"',";
	if(cb8.selected)
		zhuangTai += "'" + cb8.label +"',";
	if(cb9.selected)
		zhuangTai += "'" + cb9.label +"',";
	zhuangTai=StringUtils.trimEnd(zhuangTai, ",");
	if(zhuangTai != "")
		student.xueJiZhuangTai=zhuangTai;	
	if(ddlRuXueNian.selectedItem)
		student.ruXueNian=ddlRuXueNian.selectedItem.item;
	if(ddlMinZuC.selectedIndex != 0 && ddlMinZu.selectedItem)
	{
		student.minZu=ddlMinZu.selectedItem.item;
		model.studentInfoQueryParameter.TJMinZu= ddlMinZuC.selectedIndex==1?"=":"!=";
	}
	if(ddlGuoJiC.selectedIndex != 0 && ddlGuoJi.selectedItem)
	{
		student.guoJi=ddlGuoJi.selectedItem.item;
		model.studentInfoQueryParameter.TJGuoJi= ddlGuoJiC.selectedIndex==1?"=":"!=";
	}
	if(ddlQiaoBaoC.selectedIndex != 0 && ddlQiaoBao.selectedItem)
	{
		student.qiaoBao=ddlQiaoBao.selectedItem.item;
		model.studentInfoQueryParameter.TJQiaoBao= ddlQiaoBaoC.selectedIndex==1?"=":"!=";
	}
	if(ddlXinbie.selectedIndex != 0)
		student.xingBie=ddlXinbie.selectedItem.label;
	if(ddlSFZ.selectedIndex != 0)
		student.youWuSfz=ddlSFZ.selectedItem.label;
	if(ddlLiuShou.selectedIndex != 0)
		student.liuShou=ddlLiuShou.selectedItem.label;
	if(ddlCanJi.selectedIndex != 0)
		student.canJi=ddlCanJi.selectedIndex==1?"":ddlCanJi.selectedItem.label;
	if(ddlGuEr.selectedIndex != 0)
		student.guEr=ddlGuEr.selectedItem.label;
	if(ddlJiSu.selectedIndex != 0)
		student.jiSu=ddlJiSu.selectedItem.label;
	if(ddlNianLing.selectedIndex != 0)
		student.ruXueNianLing=6;
	
	if(ddlSchool && ddlSchool.selectedItem)
		student.xueXiaoDaiMa=ddlSchool.selectedItem.sid;
	if(ddlBanJi && ddlBanJi.selectedIndex != 0)
		student.banJi=ddlBanJi.selectedItem.item;
	var xueDuan:String="";
	if(cb11.selected)
		xueDuan += "1,";
	if(cb12.selected)
		xueDuan += "2,";
	if(cb13.selected)
		xueDuan += "3,";
	if(cb14.selected)
		xueDuan += "4,";
	xueDuan=StringUtils.trimEnd(xueDuan, ",");
	if(xueDuan != "")
		model.studentInfoQueryParameter.xueDuan=xueDuan;
	if(ddlSYXZ.selectedIndex != 0)
		student.shengYuanXingZhi=ddlSYXZ.selectedItem.label;
	if(!StringUtils.isNullOrEmpty(txtHuJiDi.text))
		student.huJiDiZhi=StringUtils.trim(txtHuJiDi.text);
	if(!StringUtils.isNullOrEmpty(txtJTZZ.text))
		student.jiaTingZhuZhi=StringUtils.trim(txtJTZZ.text);
	if(!StringUtils.isNullOrEmpty(txtSMKH.text))
		student.shiMinKa=StringUtils.trim(txtSMKH.text);
	if(ddlDiBaoHu.selectedIndex != 0)
		student.diBaoHu=ddlDiBaoHu.selectedItem.label;
	if(ddlTSBL.selectedIndex != 0)
		student.teShuBingLi=ddlTSBL.selectedItem.label;
	if(!StringUtils.isNullOrEmpty(txtDiBaoHao.text))
		student.diBaoZheng=StringUtils.trim(txtDiBaoHao.text);
	if(!StringUtils.isNullOrEmpty(txtBingLiMing.text))
		student.bingLiMing=StringUtils.trim(txtBingLiMing.text);
	
	model.studentInfoQueryParameter.studentInfo=student;
	controller.doSearch(model.studentInfoQueryParameter);
	PopUpManager.removePopUp(this);
}

protected function titlewindow1_creationCompleteHandler(event:FlexEvent):void
{
	// TODO Auto-generated method stub
	controller=new StudentInfoController(model);
}